import QtQuick 2.6
import QtQuick.Layouts 1.2
import Qt.labs.settings 1.0
import Qt.labs.controls 1.0
import QtQml.Models 2.1
import QtQuick.XmlListModel 2.0
import "../template" as Tm
import fan.qt.complex 1.0 as Lex
Tm.Navigator {
    id: nav
    title: "学员管理"

    ListView {
        id: listView
        anchors.fill: parent

        model:  XmlListModel {
            source: http.build("/member.xml?t=s", {id: usinfo.id})
            query: "/members/member"

            XmlRole { name: "id"; query: "id/string()" }
            XmlRole { name: "name"; query: "name/string()" }
            XmlRole { name: "image"; query: "image/string()" }
            XmlRole { name: "mail"; query: "mail/string()" }
            XmlRole { name: "mobile"; query: "mobile/string()" }
            XmlRole { name: "address"; query: "address/string()" }
        }


        delegate: ItemDelegate {
            width: listView.width
             height: implicitHeight * 3
            RowLayout {
                anchors.fill: parent
                anchors.margins: 9
                Image {
                   Layout.alignment: Qt.AlignVCenter
                    sourceSize: Qt.size(100,100)
                    source: "http://" + Lex.G.SERVER + image
                }

                ColumnLayout {
                    Layout.fillHeight: true
                    Layout.fillWidth: true
                    Layout.alignment: Qt.AlignLeft
                    spacing: 9
                    Label {
                        text: "姓名：" + name + " 电话：" + mobile

                        elide: Text.ElideRight
                        color: "dimgray"
                    }


                    Label {
                        text:  "邮箱：" + mail

                        verticalAlignment: Text.AlignVCenter
                    }

                    Label {
                        text:  "地址：" + address

                        verticalAlignment: Text.AlignVCenter
                    }
                }
            }

            Rectangle {
                color: "gainsboro"
                width: parent.width
                height: 1
                anchors.bottom: parent.bottom
                visible: index != listview.count - 1
            }
            onClicked: contentArea.push(Qt.resolvedUrl("../qml/MemberListContentNavigator.qml"), {title: name,
                                            uid: id, name: name})
        }

    }

}
